package com.jinlejia.feedback.weight;

import android.content.Context;
import android.util.AttributeSet;
import android.webkit.WebView;


public class CustomWebView  extends WebView {

    public CustomWebView(Context context) {
        super(context);
    }

    public CustomWebView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomWebView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }
    private boolean autoMeasure;

    public void setAutoMeasure(boolean autoMeasure) {
        this.autoMeasure = autoMeasure;
        postInvalidate();
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (autoMeasure){
            heightMeasureSpec = (int)(this.getContentHeight()*this.getScale());
            invalidate();
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
            postInvalidate();
        }else {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
            postInvalidate();
        }

    }
}
